#include <stdio.h>
#include <string.h>
#include<stdlib.h>
#include "wrizhi.h"
#include "lianjie.h"
#include "jiexi.h"

int main(int argv, char **argc) {
   getrizhi();
    //连接服务器
    int sockfd=getsock(argc[1],argc[2]);
    //密码登录
    char mm[8];
    while(1){
         printf("请输入密码：");
         gets(mm);
         write(sockfd,mm,sizeof(mm));
         read(sockfd,mm,sizeof(mm));
         if(strcmp(mm,"yyyyyyy")==0){
            break;
         }
    }
    //字符串处理
    file ff;
    memset(ff.name,0,sizeof(ff.name));
    ff.sub=NULL;
    char s[128]={0};
    int q;
    while (1) {
        printf(">");
        gets(s);
        ff=jiexi(s,ff);
        printf("命令：%d参数：%s\n",ff.s,ff.name);
        wrizhi("命令：%d参数：%s\n",ff.s,ff.name);
        int q=chuli(sockfd,ff);
        if(q==-1){
            rmrizhi();
            return 0;
        }
        memset(s,0,sizeof(s));
    }
    return 0;
}
